package com.settlement.system.common.util;

import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpSession;

/**
 * @author he.xx
 * @date 2021-07-13
 * 请求上下文工具类
 */
public class RequestContextUtils {

    /**
     * 获取session会话
     */
    public static HttpSession getHttpSession() {
        ServletRequestAttributes servletRequestAttributes = (ServletRequestAttributes)RequestContextHolder.getRequestAttributes();
        HttpServletRequest httpServletRequest = servletRequestAttributes.getRequest();
        HttpSession session = httpServletRequest.getSession();
        return session;
    }

}
